//
//  Int+Extensions.swift
//  HomeShop
//
//  Created by 刘泽 on 2018/2/11.
//  Copyright © 2018年 刘泽. All rights reserved.
//

import Foundation
import UIKit

extension Int{
    
    public func toString() -> String {
        return String(self)
    }

    public func toSecond() -> String{
        if self < 10{
            return "0" + String(self)
        }else{
            return String(self)
        }
    }
    
    public func toDouble() -> Double {
        return Double(self)
    }
    public func toCGFloat() -> CGFloat {
        return CGFloat(self)
    }
    public func toFloat() -> Float {
        return Float(self)
    }
    public func toTime(format:String = "yyyy.MM.dd") -> String{
        let timeInterval : TimeInterval = TimeInterval.init(self)
        let date = Date.init(timeIntervalSince1970: timeInterval)
        let dateFormate = DateFormatter()
        dateFormate.dateFormat = format
        return dateFormate.string(from: date)
    }

    public func toYuan() -> String{
        let double = self.toFloat()/100
        return String.init(format: "%.2f", double)
    }

}


